package cn.interestingshop.web.manager;

import cn.interestingshop.entity.BaseOrder;
import cn.interestingshop.entity.Notice;
import cn.interestingshop.entity.OrderInfo;
import cn.interestingshop.service.baseOrder.BaseOrderService;
import cn.interestingshop.service.baseOrder.BaseOrderServiceImpl;
import cn.interestingshop.service.classify.ClassifyService;
import cn.interestingshop.service.classify.ClassifyServiceImpl;
import cn.interestingshop.service.notice.NoticeService;
import cn.interestingshop.service.notice.NoticeSserviceImpl;
import cn.interestingshop.utils.ClassifyVo;
import cn.interestingshop.web.AbstractServlet;
import com.alibaba.fastjson.JSONObject;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(value = "/ZfbTbServlet")
public class ZfbTbServlet extends HttpServlet {


    public void service(HttpServletRequest request, HttpServletResponse response){



        ClassifyService classifyService=new ClassifyServiceImpl();

        List<ClassifyVo> list = classifyService.selectAll();

        NoticeService noticeService=new NoticeSserviceImpl();
        List<Notice> list1 = noticeService.selectAll();

        request.setAttribute("notice",list1);

        request.setAttribute("classifyVoList",list);


        BaseOrder order=new BaseOrder();

        order.setOrderNo(request.getParameter("out_trade_no"));

        BaseOrderService baseOrderService=new BaseOrderServiceImpl();
        int orderId = baseOrderService.xgZf(request.getParameter("out_trade_no"));
        System.out.println(orderId);


        order.setAmount(Float.parseFloat(request.getParameter("total_amount")));

        request.setAttribute("order",order);


        try {
            request.getRequestDispatcher("client/settlement/paySuccess.jsp").forward(request,response);
        } catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
